<?php
/**
 * Created by PhpStorm.
 * User: 刘抱
 * Date: 2018/12/21
 * Time: 16:48
 */

namespace Home\Services;


class ProductSupplierManageService extends BaseService
{
    public static $table = 'db_supplier';
    public static $table2 = 'db_supplier_product';

    //供应商管理列表
    public static function getResultArray($field, $where, $order)
    {
        return parent::getResultOrder(self::$table, $field, $where, $order);
    }

    //供应商类型
    public static function getProductResultOrder($field, $where, $order)
    {
        return parent::getResultOrder(self::$table2, $field, $where, $order);
    }

    //录入供应商
    public static function addSupplier($data)
    {
        $data['add_uid'] = $_SESSION['dms_uid'] ? $_SESSION['dms_uid'] : $_SESSION['uid'];
        $data['add_date'] = date('Y-m-d H:i:s');
        return parent::insertData(self::$table, $data);
    }

    //录入产品类型
    public static function addProduct($data)
    {
        $data['add_uid'] = $_SESSION['dms_uid'] ? $_SESSION['dms_uid'] : $_SESSION['uid'];
        $data['add_date'] = date('Y-m-d H:i:s');
        return parent::insertData(self::$table2, $data);
    }

    //删除
    public static function delProduct($id)
    {
        $where['id'] = $id;
        $data['del'] = '0';
        return parent::save(self::$table, $data, $where);
    }

    //获取单个供应商
    public static function getProductResult($where)
    {
        return parent::getResultByField(self::$table, '*', $where);
    }

    //更新供应商
    public static function edit($where, $data)
    {
        $data['add_uid'] = $_SESSION['dms_uid'] ? $_SESSION['dms_uid'] : $_SESSION['uid'];
        $data['add_date'] = date('Y-m-d H:i:s');
        return parent::save(self::$table, $data, $where);
    }

}